/**
 * Re-entrant tasks and recursive functions
 * 可重入任务和递归函数
 *
 * Verilog 2001 adds a new keyword: automatic. This keyword, when added to a task, 
 * makes the task re-entrant. All task declarations with automatic are allocated 
 * dynamically for each concurrent task entry.
 * Verilog 2001增加了一个新的关键字:自动。当添加到任务时，此关键字使任务可重入。
 * 所有带有automatic的任务声明都为每个并发任务条目动态分配。
 *
 * A function with added automatic keyword allows the function to be called recursively.
 * 添加了automatic关键字的函数允许递归调用该函数。
 *
 * Example : Task
 * Task示例
 * 
 */

module re_entrant_task();

task automatic print_value;
  input [7:0] value;
  input [7:0] delay;
  begin
    #(delay) $display("%g Passed Value %d Delay %d", $time, value, delay);
  end
endtask

initial begin
  fork 
    #1 print_value (10,7);
    #1 print_value (8,5);
    #1 print_value (4,2);
  join
  #1 $finish;
end

endmodule
